import request from '@/util/axios';
import type {
  CommonResultType,
  ListData,
  SubItem,
  GetDetail,
  CommonDetailResultType,
  DetailListData,
  IdList
} from './type.ts';

export enum API {
  // 获取记账列表
  LIST = 'http://192.168.43.220:9000/platform-entry/api/cost_aggregation/calculation_subject/list',
  //获取已选详情
  CHECK_LIST = 'http://192.168.43.220:9000/platform-entry/api/cost_aggregation/calculation_subject',
  //保存科目
  CREATE_LIST = 'http://192.168.43.220:9000/platform-entry/api/cost_aggregation/calculation_subject'
}

/**
 * @method  getList 获取计算账套列表
 */
export const getList = (): Promise<CommonResultType<ListData<SubItem>>> => {
  return request.get(API.LIST);
};

/**
 * @method  getCheckList 计算账套已选
 */
export const getCheckList = (
  params: GetDetail
): Promise<CommonDetailResultType<DetailListData>> => {
  return request.get(API.CHECK_LIST, { params });
};

/**
 * @method  createListDate 保存计算账套已选
 */
export const createListDate = (params: IdList): Promise<CommonResultType<null>> => {
  return request.post(API.CREATE_LIST, params);
};
